import { Module } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserEntity } from 'src/user/entities/user.entity';
import { PassportModule } from '@nestjs/passport';
import { UserService } from 'src/user/user.service';
import { JwtModule } from '@nestjs/jwt';
import { jwtExpireIn, jwtKey } from '../config';
import { JwtStrategy } from 'src/auth/strategy/jwt.strategy';
import { LocalStrategy } from './strategy/local.strategy';
import { UserModule } from 'src/user/user.module';
import { JwtAuthGuard } from './guard/auth.guard';
import { APP_GUARD } from '@nestjs/core';
import { RecordLoginService } from 'src/record_login/record_login.service';
import { RecordLoginEntity } from 'src/record_login/entities/record_login.entity';

@Module({
  imports: [
    JwtModule.register({ ...jwtKey, signOptions: { expiresIn: jwtExpireIn } }),
    JwtModule,
    TypeOrmModule.forFeature([UserEntity]),
    TypeOrmModule.forFeature([RecordLoginEntity]),
    PassportModule,
    UserModule,
  ],
  providers: [
    AuthService,
    UserService,
    RecordLoginService,
    LocalStrategy,
    JwtStrategy,
    // JwtAuthGuard,
    {
      provide: APP_GUARD,
      useClass: JwtAuthGuard,
    },
  ],
  controllers: [AuthController],
})
export class AuthModule {}
